<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/pub/head_bootstrap.inc"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=7" />
<script type="text/javascript" src="${baseURL}/js/module/bootstrap/common_edit.js"></script>

<title>${module.moduleName}-编辑</title>
</head>
<style>
	.frameBorder{
		padding-top:0px;
	}
</style>
<body class="FrameWindowBg">
	<div class="FrameWindow">
		<div class="window-menu">
		 	<div class="menuInner"></div>  
		</div>
		<!-- window-menu -->
		<div class="FrameWindowInner">
			<div class="location"><i class="fa fa-map-marker"></i>${module.moduleName}</div>
			<c:if test="${fn:length(module.childTab)>0}">
				<ul class="top-card nav nav-tabs margin-top-0">
					<li class="active"><a href="#mainTab" tabindex="-1" data-toggle="tab">基本信息</a></li>
					<c:forEach items="${module.childTab}" var="o">
 						<li><a href="#${o.tabid}" tabindex="-1" data-toggle="tab">${o.title}</a></li> 
 				    </c:forEach>
				</ul>
			</c:if>
			<!-- top-card -->
			
			<div class="cont-table tab-content">
				<!-- 机构信息 -->
				<div class="tab-pane fade in active" id="mainTab">
					<form onsubmit="return false;" id="mainform" class="table-normal" enctype="multipart/form-data"></form>
				</div>
				<!-- cont-table -->
				
				<!-- childTab信息 -->
				<c:forEach items="${module.childTab}" var="o">
					<div class="tab-pane fade frameBorder" id="${o.tabid}">
						<div class="table-sheet margin-top-0">
							<table id="tb_sltBox2"></table>
						</div>
						<!-- table-normal -->
					</div>
  				</c:forEach>
			</div>
		</div>
		<!-- FrameWindowInner -->
	</div>
	<!-- FrameWindow -->

<script type="text/javascript">

$(function(){
	$('.form_date').datetimepicker({
	    language:  'zh-CN',  
		autoclose: 1,
		minView: 2
	});
});
</script>

<script>
	var pkId = '${id}';
	var mdId = '${param.mdId}';
	var mdCode = '${param.mdCode}';
	
	BT.setFormDefaultBtn(FF_Cancel, FF_Save);
	var columns = 1;
	var dicObj = '${module.dic}';
	if(dicObj){
		dicObj = JSON.parse(dicObj);
	}
	var fieldsData = '${module.moduleFields}';
	var mainEditor = null;
	var win = parent || window;
	
	var eventObj = {};
	var editDataUrl = '${baseURL}/jdbc/common/basecommonedit/editJSON.do?id=${id}&mdId=${module.moduleId}';
	mainEditor = initForm(fieldsData, $("#mainform"), dicObj, {'width':230, 'prefix':'', 'suffix':''},columns, eventObj.mainTab);
	if (pkId){
		getEditData(editDataUrl, mainEditor.form, mainEditor.fields);
 	}
	//保存
	function FF_Save(){
		$("#mainform").attr("action","${baseURL}/company/companysave/save.do?mdId=${param.mdId}&mdCode=${param.mdCode}&strategy=${strategy}");
		BT.submitForm($("#mainform"), function (data) {
			if (data && data.hasOk) { 
				pkId = data.bean.id;
				$('#mainform input[name=id]').val(pkId);
				BT.showSuccess('操作成功!',function(){
					// 关闭窗口 刷新父窗口
				    win.LG.closeAndReloadParent("editCompany", "${param.menuId}");
				});
            } else { 
            	BT.showError("操作失败!失败信息如下:\n" + data.message + "\n如您对以上信息有疑问，请联系管理人员!");
            }
		});
	}
	
	function FF_Cancel(){
        win.LG.closeCurrentTab("editCompany");
	}

</script>
</body>
</html>
